package com.api.shopapi.mapper;

import com.api.shopapi.entity.DishesPlanNoonItem;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface DishesPlanNoonItemMapper {


    @Insert("insert into dishes_plan_noon_item" +
            "(" +
            "DishesPlanNoonItemCode," +
            "DishesPlanNoonCode," +
            "DishesCode," +
            "DishesName" +
            ") " +
            "values" +
            "(" +
            "#{dishesPlanNoonItem.DishesPlanNoonItemCode}," +
            "#{dishesPlanNoonItem.DishesPlanNoonCode}," +
            "#{dishesPlanNoonItem.DishesCode}," +
            "#{dishesPlanNoonItem.DishesName}" +
            ")")
    int insert(@Param("dishesPlanNoonItem") DishesPlanNoonItem dishesPlanNoonItem);

    @Delete("delete from dishes_plan_noon_item where dishesPlanNoonItemCode=#{dishesPlanNoonItemCode}")
    int delete(@Param("dishesPlanNoonItemCode") String dishesPlanNoonItemCode);

    @Update("update dishes_plan_noon_item" +
            " set" +
            " DishesCode=#{dishesPlanNoonItem.DishesCode}" +
            " where " +
            " dishesPlanNoonItemCode=#{dishesPlanNoonItem.dishesPlanNoonItemCode}")
    int update(@Param("dishesPlanNoonItem") DishesPlanNoonItem dishesPlanNoonItem);

    @Select("select * from dishes_plan_noon_item where dishesPlanNoonItemCode=#{dishesPlanNoonItemCode} limit 1")
    DishesPlanNoonItem getByDishesPlanNoonItemCode(@Param("dishesPlanNoonItemCode") String dishesPlanNoonItemCode);

    @Select("<script>" +
            "select * from dishes_plan_noon_item where dishesPlanNoonCode=#{dishesPlanNoonCode} " +
            "</script>")
    List<DishesPlanNoonItem> ListByDishesPlanNoonCode(@Param("dishesPlanNoonCode") String dishesPlanNoonCode);


}
